/**
 * @description:
 * @author: fan
 * @date: 2022/1/25 10:01
 * @version: 1.0
 */
//给个实例

import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.net.URL;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class ImageMove {

    static int x, y;

    public static void main(String[] args) throws Exception {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //f.getContentPane().setLayout(null);//这个要设置成 null
        //图标
        Icon icon = new ImageIcon(new URL("https://gss0.bdstatic.com/70cFsjip0QIZ8tyhnq/img/logo-zhidao.gif"));
// Icon icon = new ImageIcon("c:/logo-zhidao.gif");//本地图片文件
        JLabel l = new JLabel(icon);
        l.setSize(icon.getIconWidth(), icon.getIconHeight());
        l.setBorder(BorderFactory.createLineBorder(Color.red));
        f.getContentPane().add(l);
        f.setSize(1902,1080);
        f.setVisible(true);
        l.setLocation(l.getX(),l.getY() );
        Thread.sleep(1000);
        l.setLocation(l.getX()+200,l.getY()+200 );

//        l.addMouseListener(
//                new MouseAdapter() {
//                    public void mousePressed(MouseEvent e) {
//                        x = e.getX();
//                        y = e.getY();
//                    }
//                });
//        l.addMouseMotionListener(new MouseMotionListener() {
//            public void mouseDragged(MouseEvent e) {
//                JLabel l = (JLabel) e.getSource();
//
//            }
//
//            public void mouseMoved(MouseEvent e) {
//            }
//        });
    }
}

